package org.huang.sample03.demo3;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.ServletContextInitializer;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;

/**
 * @描述: 使用代码注册Servlet，Filter，Listener
 * @作者 Mr.Huang
 * @创建时间 2017-08-07
 * @版本: 1.0
 */

@SpringBootApplication
public class AppServer03 implements ServletContextInitializer {

    //实际上应该同一个目录下面有两个使用了@SpringBootApplication注解的类，所以它们配置的东西都会被加载。
    public static void main(String[] args) throws Exception {
        SpringApplication.run(AppServer03.class, args);
    }

    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
      servletContext.addServlet("myservlet03",new MyServlet03()).addMapping("/servlet03/*");
    }
}
